package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchAlarmArea;
import com.ruoyi.system.service.IDispatchAlarmAreaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 区域预警Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchAlarmArea")
public class DispatchAlarmAreaController extends BaseController
{
    @Autowired
    private IDispatchAlarmAreaService dispatchAlarmAreaService;

    /**
     * 查询区域预警列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAlarmArea:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchAlarmArea dispatchAlarmArea)
    {
        startPage();
        List<DispatchAlarmArea> list = dispatchAlarmAreaService.selectDispatchAlarmAreaList(dispatchAlarmArea);
        return getDataTable(list);
    }

    /**
     * 导出区域预警列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAlarmArea:export')")
    @Log(title = "区域预警", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchAlarmArea dispatchAlarmArea)
    {
        List<DispatchAlarmArea> list = dispatchAlarmAreaService.selectDispatchAlarmAreaList(dispatchAlarmArea);
        ExcelUtil<DispatchAlarmArea> util = new ExcelUtil<DispatchAlarmArea>(DispatchAlarmArea.class);
        util.exportExcel(response, list, "区域预警数据");
    }

    /**
     * 获取区域预警详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAlarmArea:query')")
    @GetMapping(value = "/{alarmAreaId}")
    public AjaxResult getInfo(@PathVariable("alarmAreaId") Long alarmAreaId)
    {
        return success(dispatchAlarmAreaService.selectDispatchAlarmAreaByAlarmAreaId(alarmAreaId));
    }

    /**
     * 新增区域预警
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAlarmArea:add')")
    @Log(title = "区域预警", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchAlarmArea dispatchAlarmArea)
    {
        return toAjax(dispatchAlarmAreaService.insertDispatchAlarmArea(dispatchAlarmArea));
    }

    /**
     * 修改区域预警
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAlarmArea:edit')")
    @Log(title = "区域预警", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchAlarmArea dispatchAlarmArea)
    {
        return toAjax(dispatchAlarmAreaService.updateDispatchAlarmArea(dispatchAlarmArea));
    }

    /**
     * 删除区域预警
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchAlarmArea:remove')")
    @Log(title = "区域预警", businessType = BusinessType.DELETE)
	@DeleteMapping("/{alarmAreaIds}")
    public AjaxResult remove(@PathVariable Long[] alarmAreaIds)
    {
        return toAjax(dispatchAlarmAreaService.deleteDispatchAlarmAreaByAlarmAreaIds(alarmAreaIds));
    }
}
